package 网络编程.tcp协议通信;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class 客户端 {
    public static void main(String[] args) throws Exception {
        var socket = new Socket("127.0.0.1",9999);
        var 字节输出流 = socket.getOutputStream();
        var 数据输出流 = new DataOutputStream(字节输出流);
        Scanner sc = new Scanner(System.in);
        while(true) {
            String s = sc.nextLine();
            数据输出流.writeUTF(s);
            数据输出流.flush();
            if(s.equals("再见"))break;
        }
        数据输出流.close();
        socket.close();
    }
}
